<template>
  <Tooltip placement="top">
    <template #title>
      <span>{{ t('common.redo') }}</span>
    </template>
    <RedoOutlined @click="redo" />
  </Tooltip>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { RedoOutlined } from '@ant-design/icons-vue';
import { useI18n } from '@/hooks/web/useI18n';
import { useTableContext } from '../../hooks/useTableContext';

export default defineComponent({
  name: 'RedoSetting',
  components: {
    RedoOutlined,
    Tooltip,
  },
  props: {
    loadClear: {
      type: Boolean,
      default: true,
    },
  },
  setup(props) {
    const table = useTableContext();
    const { t } = useI18n();

    function redo() {
      if (props.loadClear) {
        table.clearSelectedRowKeys();
      }

      table.reload();
    }

    return { redo, t };
  },
});
</script>
